﻿
namespace ApplicationGenerator.DataAccess
{
    public class MenuDataBaseCommands : IDataBaseCommands
    {
        #region SQL Commands

        private const string CreateMenuTableSchema = "CREATE TABLE AG_MENU(" +
                                                        "[AG_ID] [uniqueidentifier] NOT NULL," +
                                                        "[AG_NAME] [nvarchar](50) NOT NULL UNIQUE NONCLUSTERED," +
                                                        "[AG_BINARY_DATA] [varbinary](max) NOT NULL" +
                                                        ")";
        private const string InsertToAgMenuTable = "INSERT INTO AG_MENU  VALUES(@id,@name,@binData)";
        private const string SelectMenuFromAgMenuTable = "SELECT AG_BINARY_DATA FROM AG_MENU WHERE AG_ID = @id;";
        private const string SelectMenuFromAgListsTableByName = "SELECT AG_BINARY_DATA FROM AG_MENU " +
                                                                "WHERE AG_NAME = @name;";
        private const string UpdateMenuFromAgMenuTable = "UPDATE AG_MENU SET AG_BINARY_DATA = @bin_data WHERE AG_NAME = @name;";
        private const string SelectMenuNames = "SELECT AG_NAME FROM AG_MENU;";
        private const string SelectVersionInfoFromAgMenuTable = "SELECT AG_ID,AG_NAME FROM AG_MENU";

        #endregion

        #region Methods

        public string CreateTableCommand()
        {
            return CreateMenuTableSchema;
        }

        public string InsertToTableCommand()
        {
            return InsertToAgMenuTable;
        }

        public string UpdateToTableCommand()
        {
            return UpdateMenuFromAgMenuTable;
        }

        public string SelectFromTableCommand()
        {
            return SelectMenuFromAgMenuTable;
        }

        public string SelectFromTableByNameCommand()
        {
            return SelectMenuFromAgListsTableByName;
        }

        public string SelectNames()
        {
            return SelectMenuNames;
        }

        public string SelectVersionInfo()
        {
            return SelectVersionInfoFromAgMenuTable;
        }

        public string SelectName()
        {
            return "";
        }

        #endregion
    }
}
